package com.five.controller;

import com.five.pojo.ClubInform;
import com.five.pojo.Result;
import com.five.service.ClubInformService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "社团通知接口")
@RestController
@CrossOrigin
@RequestMapping("/clubInform")
public class ClubInformController {
    @Autowired
    private ClubInformService clubInformService;

    //管理员发布系统通知
    @Operation(summary = "管理员发布系统通知")
    @PostMapping("/add")
    public Result add(@RequestBody ClubInform clubInform){
        clubInformService.addInform(clubInform);
        return Result.success();
    }
    //管理员审核团长发布的通知
    @Operation(summary = "管理员审核发布的通知(管理员)")
    @PatchMapping("/ModStatus")
    public Result ModStatus(Integer status , Integer id){
        clubInformService.ModStatus(status , id);
        return Result.success();
    }

    //查看所有活动通知详情信息
    @Operation(summary = "查看活动通知详情消息(学生)")
    @GetMapping("/findInform")
    public Result findInform(){
        List<ClubInform> clubInformList = clubInformService.findInform();
        return Result.success(clubInformList);
    }

    //管理员删除通知
    @Operation(summary = "管理员删除通知(管理员)")
    @DeleteMapping
    public Result deleteInform(Integer id){
        clubInformService.deleteInform(id);
        return Result.success();
    }

    //管理员修改通知
    @Operation(summary = "管理员修改通知")
    @PutMapping("/update")
    public Result updateInForm(@RequestBody ClubInform clubInform){
        clubInformService.updateInForm(clubInform);
        return Result.success();
    }

}
